package com.chengqj.model;

import java.io.Serializable;
import java.io.UnsupportedEncodingException;

import org.springframework.util.StringUtils;

import com.chengqj.pojo.TArticle;
import com.chengqj.util.DateUtil;

public class TArticleModel implements Serializable{
	private int id;
	private String title;
	private String createDate;
	private String author;
	private String type;
	private String publishDate;
	private String outImageUrl;
	private String inImageUrl;
	private String context;
	private String smallType;
	private String keyContext;
	private String hrefUrl;
	private String smallTypeName;
	public String getHrefUrl() {
		return hrefUrl;
	}
	public String getSmallTypeName() {
		return smallTypeName;
	}
	public void setSmallTypeName(String smallTypeName) {
		this.smallTypeName = smallTypeName;
	}
	public void setHrefUrl(String hrefUrl) {
		this.hrefUrl = hrefUrl;
	}
	public String getSmallType() {
		return smallType;
	}
	public void setSmallType(String smallType) {
		this.smallType = smallType;
	}
	public String getKeyContext() {
		return keyContext;
	}
	public void setKeyContext(String keyContext) {
		this.keyContext = keyContext;
	}
	public static TArticleModel createTArticleModel(TArticle a){
		TArticleModel model = new TArticleModel();
		model.setId(a.getId());
		model.setTitle(a.getTitle());
		model.setCreateDate(DateUtil.getYYYYMMDD(a.getCreateDate()));
		model.setAuthor(a.getAuthor());
		model.setKeyContext(a.getKeyContext());
		if(a.getType()==1){
			model.setType("慢生活");	
			model.setHrefUrl("main/manlife");
		}else if(a.getType()==2){
			model.setType("碎言碎语");	
			model.setHrefUrl("/");
		}else if(a.getType()==3){
			model.setType("学无止境");	
			model.setHrefUrl("main/suiyansuiyu");
			if(a.getSmallType()==1){
				model.setSmallTypeName("系统架构");
			}else if(a.getSmallType()==2){
				model.setSmallTypeName("数据库");
			}else if(a.getSmallType()==3){
				model.setSmallTypeName("网站部署");
			}else if(a.getSmallType()==4){
				model.setSmallTypeName("Linux系统");
			}else if(a.getSmallType()==5){
				model.setSmallTypeName("其他");
			}
		}
		model.setSmallType(a.getSmallType()+"");
		model.setPublishDate(DateUtil.getYYYYMMDD(a.getPublishDate()));
		model.setOutImageUrl(a.getOutImageUrl());
		String inImageurl = a.getInImageUrl();
		if(StringUtils.isEmpty(inImageurl)){
			model.setInImageUrl(null);
		}else{
			model.setInImageUrl(inImageurl);
		}
		model.setContext(a.getContext());
		return model;
	}
	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getCreateDate() {
		return createDate;
	}

	public void setCreateDate(String createDate) {
		this.createDate = createDate;
	}

	public String getAuthor() {
		return author;
	}

	public void setAuthor(String author) {
		this.author = author;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public String getPublishDate() {
		return publishDate;
	}

	public void setPublishDate(String publishDate) {
		this.publishDate = publishDate;
	}

	public String getOutImageUrl() {
		return outImageUrl;
	}

	public void setOutImageUrl(String outImageUrl) {
		this.outImageUrl = outImageUrl;
	}

	public String getInImageUrl() {
		return inImageUrl;
	}

	public void setInImageUrl(String inImageUrl) {
		this.inImageUrl = inImageUrl;
	}

	public String getContext() {
		return context;
	}

	public void setContext(String context) {
		this.context = context;
	}
}
